package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.dto.StudentAndClazzDTO;
import com.itheima.po.*;
import com.itheima.pojo.Emp;
import com.itheima.pojo.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StudentMapper {

   Page<StudentAndClazzDTO> selectStudent(@Param("p") StudentPageParam param);

   int insertStudent(@Param("s") InsertStudent student);

   /**
    * 插入前判断学号是否存在
    * @param no
    * @return
    */
   @Select("select id,no from student where no = #{no}")
   IsExists selectIsExists(String no);

   int deleteByIds(List<Integer> ids);

   @Select("select id,name,no,gender,phone,degree,id_card,is_college,address,graduation_date,clazz_id,create_time," +
           "violation_score,violation_count,update_time from student where id = #{id}")
   SelectStudentById selectStudentById(Integer id);

   int updateStudent(UpdateStudent student);

   @Update("update student set violation_count = violation_count + 1 , violation_score = violation_score + #{score} where id = #{id}")
   int violation(@Param("id") Integer id,@Param("score") Integer score);

   /**
    * 登录
    */

}
